package com.cloud.rocketmq.listener;

import com.cloud.rocketmq.entity.User;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic = "rocketMq", consumerGroup = "OneReceive") //topic要与生产者的topic一致
public class consumer implements RocketMQListener<User> {
    // 报错就会重新消费，所以可以try catch
    @Override
    public void onMessage(User msg) {
        System.out.println("接受到的信息为" + msg);
    }
}